<template>
  <div class="courts-select">
    <!-- 模糊搜索 -->
    <el-select
      v-model="filterValue"
      clearable
      filterable
      :placeholder="placeholder"
      @change="filterChange"
    >
      <el-option
        v-for="dict in userIdOptions"
        :key="dict.userId"
        :label="dict.name"
        :value="dict.userId"
      />
    </el-select>
  </div>
</template>

<script>
import { getUserEnum } from "@/api/ehr/enum";
// import { getDefaultApprover } from "@/api/ehr/person";
export default {
  name: "",
  data() {
    return {
      userIdOptions: [],
      filterValue: "",
      loading: false,
      noMatchText: "暂无数据",
    };
  },
  props: {
    list: Array,
    placeholder: {
      type: String,
      default: "请输入xxx",
    },
  },
  created() {
    this.getUserEnumData();
  },
  methods: {
    // 系统用户数据
    getUserEnumData() {
      this.loading = true; // 开始拿数据
      getUserEnum().then((response) => {
        this.userIdOptions = response.data;
      });
      // 按用户的partyId 获取默认审批人
      // console.info("partyId:" + this.$store.state.user.partyId);
      // console.info("defaultApprover:" + this.$store.state.user.defaultApprover);
      this.filterValue = this.$store.state.user.defaultApprover * 1;
      // getDefaultApprover(this.$store.state.user.partyId).then((response) => {
      //     var userId = response.approver;
      //     console.debug("userId:" + userId);
      //     if(userId)
      //     this.filterValue = userId*1;
      // });
      this.loading = false;
    },
    // 查询选择
    filterChange(e) {
      this.$emit("getSelectedCourt", e);
      this.filterValue = e;
    },
  },
};
</script>

